package cn.xiaowenjie.common.beans;

import lombok.Data;

import java.io.Serializable;

/**
 * 统一的接口返回格式，就是ResultBean，分页的有另外一个PageResultBean
 * <p>
 * User: tang-zhong-wei 2019/7/30 17:06
 * Reference: https://xwjie.github.io/rule/rest-defined.html#%E8%BF%94%E5%9B%9E%E6%A0%BC%E5%BC%8F%E4%B8%8D%E7%BB%9F%E4%B8%80
 * Test:
 */
@Data
public class ResultBean<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	public static final int NO_LOGIN = -1;

	public static final int SUCCESS = 0;

	public static final int FAIL = 1;

	public static final int NO_PERMISSION = 2;

	private String msg = "success";

	private int code = SUCCESS;

	private T data;

	public ResultBean() {
		super();
	}

	public ResultBean(T data) {
		super();
		this.data = data;
	}

	public ResultBean(Throwable e) {
		super();
		this.msg = e.toString();
		this.code = FAIL;
	}
}
